package com.bes.sdk.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SettingsJsonUtils {
	public static final String SETTINGS = "Settings";
	public static final String WORKOUT_JSON = "workouts.json";
	public static final String WORKOUTS_FOLDER = "Workouts";
	public static final String PANEL_JSON = "sports_profiles";
	public static final String GEAR_PROFILE_JSON = "gear_profile.json";
	public static final String SETTING_JSON = "settings.json";
	public static final String LOCATION_JSON = "location.json";
	public static final String USERPROFILE_JSON = "user_profile.json";
	public static final String WIFI_OTA_JSON = "wifi_ota.json";
	public static final String ROUTE_BOOKS_JSON = "routebooks.json";
	public static final String BB_OFFLINE_LOG_JSON = "upload_log_file_list.txt";
	public static final String ROUTE_BOOKS_FOLDER = "Routebooks";
	public static final String DEVICE_INFO = "device_info";
	public static final String DEVICE_MODEL = "device_model";
	public static final String DEVICE_SN = "sn";
	public static final String DEVICE_MODEL_DEFAULT = "Lanxing";
	public static final String DEVICE_SN_DEFAULT = "123456";
	public static final String DEVICE_LOG = "DeviceLog";

	public static void saveDeviceInfo(Context context, String deviceMode, String sn) {
		if (context == null || deviceMode == null || sn == null) {
			return;
		}

		SharedPreferences deviceInfoPreference = context.getSharedPreferences(SettingsJsonUtils.DEVICE_INFO, Context.MODE_PRIVATE);
		SharedPreferences.Editor editor = deviceInfoPreference.edit();
		editor.putString(DEVICE_MODEL, deviceMode);
		editor.putString(DEVICE_SN, sn);
		editor.apply();
	}

	public static String getDeviceModel(Context context) {
		SharedPreferences deviceInfoPreference = context.getSharedPreferences(SettingsJsonUtils.DEVICE_INFO, Context.MODE_PRIVATE);
		return deviceInfoPreference.getString(DEVICE_MODEL, DEVICE_MODEL_DEFAULT);
	}

	public static String getSn(Context context) {
		SharedPreferences deviceInfoPreference = context.getSharedPreferences(SettingsJsonUtils.DEVICE_INFO, Context.MODE_PRIVATE);
		return deviceInfoPreference.getString(DEVICE_SN, DEVICE_SN_DEFAULT);
	}
}
